#include <iostream>
using namespace std;


int sum,n;
int d(int a){
    if(a <= n){
        sum+=1;
    }
    if(a > n/10){
        return sum;
    }
    d(a*10);
    d(a*10+1);
    return -1;
}

int main() {
    cin >> n;
    d(1);
    cout << sum;
    return 0;
}